package wortubung;

import wortubung.core.LANG;
import wortubung.util.TransliterateException;

public class InputMethodHelp {

    public static void showHelp(WortUbung wortUbung) {
		String sp = "          ";
    	try {
			wortUbung.promptln(
					"Input methods for non-English letters:\n\n" +
			        " 1. Latin letters with diacritical marks and ligatures (input only shows upper case):\n" +
			        "   ", al("'A"), al("'E"), al("'I"), al("'O"), al("'U"), al("AE"), al("OE"), "\n" +
			        "   ", al("`A"), al("`E"), al("`I"), al("`O"), al("`U"),                     "\n" +
			        "   ", al("^A"), al("^E"), al("^I"), al("^O"), al("^U"), al("^C"),           "\n" +
			        "   ", al(":A"), al(":E"), al(":I"), al(":O"), al(":U"),                     "\n" +
			        "   ", al("-A"), al("-E"), al("-I"), al("-O"), al("-U"),                     "\n" +
			        "   ", al("[A"), al("[E"), al("[I"), al("[O"), al("[U"), al("[C"), al("[N"), "\n" +
			        "   ", al("~A"), al("~E"), al("~I"), al("~O"), al("~U"), sp,       al("~N"), "\n" +
			        "   ", sp,       sp,       sp,       al("/O"), sp,       al(",C"),           "\n" +
					"    To use the symbols as-is, escape with a backslash (\\) like so: \\'a. \n\n" +

			        " 2. Russian transliteration (Latin transliteration only shows upper case):\n" +
			        "   ", ru("A"), ru("B"), ru("V"),  ru("G"),  ru("D"),  ru("JE"), ru("JO"), ru("ZH"), ru("Z"), ru("I"),  ru("J"), "\n" +
			        "   ", ru("K"), ru("L"), ru("M"),  ru("N"),  ru("O"),  ru("P"),  ru("R"),  ru("S"),  ru("T"), ru("U"),  ru("F"), "\n" +
			        "   ", ru("X"), ru("C"), ru("CH"), ru("SH"), ru("SX"), ru("\""), ru("Y"),  ru("'"),  ru("E"), ru("JU"), ru("JA"), "\n" +
			       	"    To use a character as-is, escape with a backslash (\\) like so: \\a\\b\\c. \n" +
			       	"    To use a string of characters as-is, quote in double backslashes like so: \\\\abcdefg\\\\.\n\n" +

			        " 3. Greek transliteration (Latin transliteration only shows upper case):\n" +
			        "    >", el("A"), el("B"), el("G"), el("D"), el("E"), el("Z"),  el("EH"), el("TH"), "\n" +
			        "     ", el("'A"),sp,      sp,      sp,      el("'E"),sp,       el("'EH"),          "\n" +
//       	        "     ", el("`A"),sp,      sp,      sp,      el("`E"),sp,       el("`EH"),          "\n" +
			        "    >", el("I"), el("K"), el("L"), el("M"), el("N"), el("X"),  el("O"),  el("P"),  "\n" +
			        "     ", el("'I"),sp,      sp,      sp,      sp,      sp,       el("'O"),           "\n" +
			        "     ", el(":I"), "\n" +
//       	       	"     ", el("`I"),sp,      sp,      sp,      sp,      sp,       el("`O"),           "\n" +
			        "    >", el("R"), el("S"), "\u03C2  T -> \u03A4\u03C4", el("U"), el("F"),  el("CH"), el("PS"), el("OH"), "\n" +
			        "     ", sp,      sp,      sp,      el("'U"),sp,      sp,       sp, el("'OH"),      "\n" +
//              	"     ", sp,      sp,      sp,      el("`U"),sp,      sp,       sp, el("`OH"),      "\n" +
			       	"     ", sp,      sp,      sp,      el(":U"), "\n" +
			       	"    To use a character as-is, escape with a backslash (\\) like so: \\a\\b\\c. \n" +
			       	"    To use a string of characters as-is, quote in double backslashes like so: \\\\abcdefg\\\\.\n"
					);
		} catch (TransliterateException e) {
			e.printStackTrace();
		}
    }

    private static String al(String input) throws TransliterateException {
    	String upper = LANG.la.toVernacular(input);
    	if (upper.length() == 2) // does not exist
    		return "          ";
    	String lower = LANG.la.toVernacular(input.toLowerCase());
    	return "  " + input + " -> " + upper + lower;
    }

    private static String ru(String input) throws TransliterateException {
    	String tmp = input;
    	if (input.startsWith("_"))
    		tmp += 'A';
    	String upper = LANG.ru.toVernacular(tmp);
    	String lower = LANG.ru.toVernacular(tmp.toLowerCase());
    	if (input.length() == 1)
    		input = " " + input;
    	return "  " + input + " -> " + upper.charAt(0) + lower.charAt(0);
    }

    private static String el(String input) throws TransliterateException {
    	String upper = LANG.el.toVernacular(input);
    	String lower = LANG.el.toVernacular(input.equals("S") ? "sa" : input.toLowerCase());
    	switch (input.length()) {
    	case 1: input = "  " + input; break;
    	case 2: input = " " + input; break;
    	}
    	return " " + input + " -> " + upper.charAt(0) + lower.charAt(0);
    }
}
